import React, { Component } from 'react';
import { connect } from 'react-redux'
import { changeMsg, fetchData } from './store'
import './index.scss'

@connect(
    state => ({
        Home: state.Home
    }),
    { changeMsg, fetchData }
)
class Home extends Component {
    render() {
        const { changeMsg, fetchData } = this.props
        const { list } = this.props.Home
        console.log('render触发')
        return (
            <div className="Home">
                <p onClick={() => { changeMsg('msg修改成功') }}>Home</p>
                <p onClick={() => { fetchData() }}>请求数据</p>
                {
                    list.map(item => (<p key={item.name + Math.random()}>{item.name}</p>))
                }
                {this.props.Home.msg}
            </div>
        );
    }
}

export default Home;